<template>
  <div>
    <!-- 面包屑导航条 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/toOneList' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>数据中心</el-breadcrumb-item>
      <el-breadcrumb-item>客户管理管理</el-breadcrumb-item>
      <el-breadcrumb-item>客户信息添加</el-breadcrumb-item>
    </el-breadcrumb>

      <!--标题-->
      <el-row class="box2">
        <h1 class="title">添加界面</h1>
      </el-row>
      <!--中间间隔-->
    <el-card class="box-card">
      <!--添加客户-->
        <el-form :model="form" label-width="70px"  :rules="rules">
          <el-row :gutter="22">
            <el-col :span="11">
              <el-form-item label="编号">
                <el-input v-model="form.code"  size="small" disabled></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="描述" prop="remarks">
                <el-input v-model="form.remarks"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="22">
            <el-col :span="11">
              <el-form-item label="客户名称" prop="name">
                <el-input v-model="form.name"  size="small"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="首次合作时间">
                <el-date-picker placeholder="选择日期" style="width: 100%;" type="date"
                                v-model="form.cooperDate"  size="small"> </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="22">
            <el-col :span="11">
              <el-form-item label="发票类型">
                <el-select  v-model="form.invoiceType" placeholder="请选择">
                  <el-option  label="增值税普通发票" :value="0"></el-option>
                  <el-option label="增值税专用" :value="1"></el-option>
                </el-select>

              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="发票抬头">
                <el-input v-model="form.invoiceTitle"  size="small"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="22">
            <el-col :span="11">
              <el-form-item label="税号">
                <el-input v-model="form.invoiceNum"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="税率">
                <el-input v-model="form.taxRate"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="22">
            <el-col :span="11">
              <el-form-item label="公司地址">
                <el-input v-model="form.address"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="所属行业">
                <el-select  v-model="form.industry" placeholder="请选择">
                  <el-option  label="机械制造" :value="0"></el-option>
                  <el-option label="房地产" :value="1"></el-option>
                  <el-option  label="金融" :value="2"></el-option>
                  <el-option label="教育" :value="3"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

        </el-form>
      <el-button @click="saveCustomer()" plain type="info">添加</el-button>
      <el-button @click="reset()" type="primary">重置</el-button>
      <el-button @click="goback()">返回</el-button>
    </el-card>
</div>
</template>

<script>
    export default {
        name: "CustomerAdd",
      data(){
          return{
            form:{
              code:null,
            },
            rules: {
              name: [
                { required: true, message: '请输入姓名', trigger: 'blur' },
              ],

              remarks: [
                { required: true, message: '请输入描述', trigger: 'blur' },
              ]
            }
          }

      },
      methods:{
        goback(){
          this.$router.push('/Customer');
        },
        saveCustomer:function(){
          this.$http.post("/customer/save", this.form).then((res) => {
            //如何提示
            if (res.data.success) {
              this.$message({
                message: res.data.message,
                type: 'success'
              });
            } else {
              this.$message.error(res.data.message);
            }
          });
        },
        reset(){//重置
          this.form={};
        },
      },
      mounted(){
        this.form.code=parseInt(Math.random()*1000000);
      }
    }
</script>

<style scoped>
  .row-bg {/*添加界面布局的样式*/
    padding: 10px 0;
  }
  .box2{/*添加界面的样式*/
    height: 80px;
    border-radius: 40px;
  }
  .box-card{/*列表的样式*/
    border-radius: 30px;
  }
  .box{/*中间的间隔*/
    height: 20px;
    background-color: #eaedf1;
  }
  .title{
    line-height:2.3px;
    text-align: center;
  }
</style>
